package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.shop.ShopRangeDto;
import com.java110.intf.shop.IShopRangeInnerServiceSMO;
import com.java110.po.shop.ShopRangePo;
import com.java110.mall.shop.dao.IShopRangeServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 店铺经营范围内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopRangeInnerServiceSMOImpl extends BaseServiceSMO implements IShopRangeInnerServiceSMO {

    @Autowired
    private IShopRangeServiceDao shopRangeServiceDaoImpl;


    @Override
    public int saveShopRange(@RequestBody ShopRangePo shopRangePo) {
        int saveFlag = 1;
        shopRangeServiceDaoImpl.saveShopRangeInfo(BeanConvertUtil.beanCovertMap(shopRangePo));
        return saveFlag;
    }

     @Override
    public int updateShopRange(@RequestBody  ShopRangePo shopRangePo) {
        int saveFlag = 1;
         shopRangeServiceDaoImpl.updateShopRangeInfo(BeanConvertUtil.beanCovertMap(shopRangePo));
        return saveFlag;
    }

     @Override
    public int deleteShopRange(@RequestBody  ShopRangePo shopRangePo) {
        int saveFlag = 1;
        shopRangePo.setStatusCd("1");
        shopRangeServiceDaoImpl.updateShopRangeInfo(BeanConvertUtil.beanCovertMap(shopRangePo));
        return saveFlag;
    }

    @Override
    public List<ShopRangeDto> queryShopRanges(@RequestBody  ShopRangeDto shopRangeDto) {

        //校验是否传了 分页信息

        int page = shopRangeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopRangeDto.setPage((page - 1) * shopRangeDto.getRow());
        }

        List<ShopRangeDto> shopRanges = BeanConvertUtil.covertBeanList(shopRangeServiceDaoImpl.getShopRangeInfo(BeanConvertUtil.beanCovertMap(shopRangeDto)), ShopRangeDto.class);

        return shopRanges;
    }


    @Override
    public int queryShopRangesCount(@RequestBody ShopRangeDto shopRangeDto) {
        return shopRangeServiceDaoImpl.queryShopRangesCount(BeanConvertUtil.beanCovertMap(shopRangeDto));    }

    public IShopRangeServiceDao getShopRangeServiceDaoImpl() {
        return shopRangeServiceDaoImpl;
    }

    public void setShopRangeServiceDaoImpl(IShopRangeServiceDao shopRangeServiceDaoImpl) {
        this.shopRangeServiceDaoImpl = shopRangeServiceDaoImpl;
    }
}
